import uvicorn
from appCustomers.models.db import engine
from appCustomers.routers import customers
from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi

app = FastAPI()
app.include_router(customers.router)

@app.on_event("shutdown")
async def shutdown():
    engine.dispose()

def custom_openapi():
    if app.openapi_schema:
        return app.openapi_schema
    openapi_schema = get_openapi(
        title="My Minibank.Cutomer Service",
        version="1.0.0",
        description="Сервисы для управления клиентами в проекте MinibankIK",
        routes=app.routes,
    )
    app.openapi_schema = openapi_schema
    return app.openapi_schema

app.openapi = custom_openapi

#ik потребуется для запуска приложения внутри контейнера
if 1 == 0:
    uvicorn.run(app, host="127.0.0.1", port=8000)
